﻿using OpenTK.Mathematics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AssetImporter.MathExts
{
    public class MathQuat
    {
		public static Quaternion FromToRotation(Vector3 fromVector, Vector3 toVector)
		{
			Vector3 w = Vector3.Cross(fromVector, toVector);
			Quaternion q = new Quaternion(w.X, w.Y, w.Z, Vector3.Dot(fromVector, toVector));
			q.W += MathF.Sqrt(fromVector.LengthSquared * toVector.LengthSquared);
			q.Normalize();

			return q;
		}
	}
}
